home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.internetmci.com!iol!usenet
- From: mat8033@iol.ie (Stuart Mc Bride)
- Newsgroups: comp.lang.c++
- Subject: Re: Getting the system time and date
- Date: Mon, 22 Jan 1996 08:01:12 GMT
- Organization: Ireland On-Line
- Message-ID: <4duk43$8ql@barnacle.iol.ie>
- References: <tate.1.002C7F92@netwest.com>
- NNTP-Posting-Host: dialup-103.dublin.iol.ie
- X-Newsreader: Forte Free Agent 1.0.82
-
- tate@netwest.com (Tate Griffin) wrote:
-
- >How do I get the current time and date from a PC using C++?
-
- Very easy, it's in the help file of BC3.1, but if you don't have
- that, here's how to do it:
-
- #include <stdio.h>
- #include <dos.h>
-
- void main()
- {
- struct dostime_t t;
- struct dosdate_t d;
-
- _dos_gettime(&t);
- _dos_getdate(&d);
-
- printf("The date and time are: ");
- printf("%2d:%02d:%02d.%02d %d/%d/%d\n",t.hour,
- t.minute,t.second,t.hsecond,d.day,d.month,
- d.year);
-
- return;
- }
-
- As you can see, the functions _dos_gettime and _dos_getdate
- store the time and date in predefined structs, and can be read
- as demonstrated in the example. This reads the dos clock,
- there's other functions to read the system clock if you really
- want to. Hope that helps.
-
-
- --- Stuart --- mat8033@iol.ie
- c2smcbri@compapp.dcu.ie
-
- http://www.compapp.dcu.ie/~c2smcbri
-
-